package com.ww.springstudy.config.fullOrLite;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FullConfig {

    @Bean
    public User userA() {
        User user = new User();
        user.setName("userA");
        return user;
    }


    @Bean
    public User userB() {
        User user = new User();
        user.setName("userB");

        //full模式下：调用userA()多少次都是返回容器中注入的同一个Bean
        System.out.println("userB1:" + System.identityHashCode(userA()));
        System.out.println("userB2:" + System.identityHashCode(userA()));
        System.out.println("userB3:" + (userA() == userA())); //true

        return user;
    }

    private static class InnerConfig {
        @Bean
        private final User userInner() {
            User user = new User();
            user.setName("userInner");
            return user;
        }
    }

}
